package com.ibeeking.found.cms.api.feign.fallback;

import com.ibeeking.found.cms.api.common.dto.CmsShopModuleInfoDTO;
import com.ibeeking.found.cms.api.feign.CmsSystemCpClient;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;


/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class CmsSystemCpFallbackFactory implements FallbackFactory<CmsSystemCpClient> {
    @Override
    public CmsSystemCpClient create(Throwable throwable) {
        return new CmsSystemCpClient() {
            @Override
            public ResponseResult<CmsShopModuleInfoDTO> cmsShopModuleInfo(Long shopId) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询店铺信息失败。");
            }
        };
    }
}
